import _axios, { get, put, _delete } from '@/lin/plugin/axios'

class Order {
  // 订单管理、列表，查询
  async getOrderList() {
    const res = await get('v1/order/page')
    return res
  }

  // 订单管理、新增
  async addOrderHandler(data) {
    return _axios({
      method: 'post',
      url: 'v1/order',
      data,
    })
  }

  // 订单管理、修改
  async editOrder(id, info) {
    const res = await put(`v1/order/${id}`, info)
    return res
  }

  // 订单管理、查询修改详情
  async getEditOrderDetail(id) {
    const res = await get(`v1/order/${id}`)
    return res
  }

  // 订单管理、软删除
  async soft_delete_Order(orderNo) {
    return _axios({
      method: 'post',
      url: `order/cancel/${orderNo}`,
    })
  }

  // 订单管理、真删除
  async reallyDelete_Order(orderNo) {
    const res = await _delete(`v1/order/${orderNo}`)
    return res
  }

  // 订单管理、发货审核
  async toExamine_Order(orderNo) {
    return _axios({
      method: 'post',
      url: `v1/order/approve/${orderNo}`,
    })
  }

  // 仓库
  async getWarehouseList() {
    const res = await get('v1/order/getWarehouses')
    return res
  }
}

export default new Order()
